home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / vbcc-ppc-src / ar / lists.c < prev    next >
C/C++ Source or Header  |  1999-01-01  |  2KB  |  84 lines

  1. /* $VER: ar lists.c V0.1 (31.01.98)
  2.  *
  3.  * This file is part of ar, a portable archive maintanance
  4.  * utility for normal and BSD-style archives.
  5.  * Copyright (c) 1999  Frank Wille
  6.  *
  7.  * ar is freeware and part of the portable and retargetable ANSI C
  8.  * compiler vbcc, copyright (c) 1995-99 by Volker Barthelmann.
  9.  * ar may be freely redistributed as long as no modifications are
  10.  * made and nothing is charged for it. Non-commercial usage is allowed
  11.  * without any restrictions.
  12.  * EVERY PRODUCT OR PROGRAM DERIVED DIRECTLY FROM MY SOURCE MAY NOT BE
  13.  * SOLD COMMERCIALLY WITHOUT PERMISSION FROM THE AUTHOR.
  14.  *
  15.  *
  16.  * v0.1  (31.01.99) phx
  17.  *       First working version, which only supports 'q' (quick append)
  18.  *       and 't' (table of contents), reads and writes normals and
  19.  *       BSD-style archives. Symbol table will not be created!
  20.  * v0.0  (29.01.99) phx
  21.  *       File created.
  22.  */
  23.  
  24. #include "ar.h"
  25. #include "lists.h"
  26.  
  27.  
  28.  
  29. void initlist(struct list *l)
  30. /* initializes a list structure */
  31. {
  32.   l->first = (struct node *)&l->dummy;
  33.   l->dummy = NULL;
  34.   l->last = (struct node *)&l->first;
  35. }
  36.  
  37.  
  38. void insertbefore(struct node *n,struct node *sn)
  39. /* insert node n directly before node sn */
  40. /* sn must be a real node - no dummy nodes allowed! */
  41. {
  42.   struct node *pn = sn->pred;
  43.  
  44.   n->next = sn;
  45.   n->pred = pn;
  46.   pn->next = sn->pred = n;
  47. }
  48.  
  49.  
  50. void insertbehind(struct node *pn,struct node *n)
  51. /* insert node n directly behind node pn */
  52. /* pn must be a real node - no dummy nodes allowed! */
  53. {
  54.   struct node *sn = pn->next;
  55.  
  56.   n->next = sn;
  57.   n->pred = pn;
  58.   pn->next = sn->pred = n;
  59. }
  60.  
  61.  
  62. void addhead(struct list *l,struct node *n)
  63. /* add node as first element of list */
  64. {
  65.   struct node *fn = l->first;
  66.  
  67.   n->pred = fn->pred;
  68.   fn->pred = n;
  69.   n->next = fn;
  70.   l->first = n;
  71. }
  72.  
  73.  
  74. void addtail(struct list *l,struct node *n)
  75. /* add node as last element of list */
  76. {
  77.   struct node *ln = l->last;
  78.  
  79.   n->next = ln->next;
  80.   ln->next = n;
  81.   n->pred = ln;
  82.   l->last = n;
  83. }
  84.